<?php 
// echo shell_exec("whoami"); exit;
// $requestBody = file_get_contents("php://input");
// $content = json_decode($requestBody, true);
// var_dump($content['password']);
// var_dump($content['ref']);
// exit;
$savePath = "/data/host/test/";
$gitPath = "https://gitee.com/suifengershi/laraver.git";//一定要使用ssh方式不然每次都得输入密码
$email = "355073025@qq.com";
$name = "随风而行";
$git = "/usr/local/git/bin/";
$password = "gitpull123456";
$branch = "master";
/**
* 优化Log输出内容
* Last Update: Feb 7th, 2018
* Author: MrN1u
*/

$requestBody = file_get_contents("php://input");
if (empty($requestBody)) {
	die('send fail没有请求数据!');
}
$content = json_decode($requestBody, true);
if($content['password'] == $password){
	if ($content['ref']=="refs/heads/$branch") {
		$result = shell_exec("cd $savePath && git clean -f && git pull origin $branch 2>&1");
		echo $result;
		echo '更新成功';exit;
	}
	echo '更新失败';exit;
} else {
	echo 'Password is Incorrect!';
}
